/**
 * Copyright (c) 2017-2024 Nop Platform. All rights reserved.
 * Author: canonical_entropy@163.com
 * Blog:   https://www.zhihu.com/people/canonical-entropy
 * Gitee:  https://gitee.com/canonical-entropy/nop-entropy
 * Github: https://github.com/entropy-cloud/nop-entropy
 */
package com.gitee.wsl.struct.table.impl

import com.gitee.wsl.struct.table.ICell


class BaseRow : AbstractRow() {

    override val cells: MutableList<ICell?> = ArrayList()

    override var id: String? = null
    override var styleId: String? = null
    override var height: Double? = null

    override var isHidden: Boolean = false
        set(hidden) {
            checkAllowChange()
            field = hidden
        }

    /*fun setStyleId(styleId: String?) {
        checkAllowChange()
        this.styleId = styleId
    }*/

   /* protected fun outputJson(out: IJsonHandler) {
        super.outputJson(out)
        if (id != null) out.put("id", id)
        if (styleId != null) out.put("styleId", styleId)
        if (height != null) out.put("height", height)
        if (isHidden) out.put("hidden", true)
        out.put("cells", cells)
    }*/

    override fun freeze(cascade: Boolean) {
        super.freeze(cascade)
        if (cascade) {
            for (cell in cells) {
                cell?.freeze(true)
            }
        }
    }

    override fun makeCell(colIndex: Int): ICell {
        var cell: ICell? = getCell(colIndex)
        if (cell == null) {
            val bc = BaseCell()
            internalSetCell(colIndex, bc)
            cell = bc
        }
        return cell
    }
}